package com.yunjie.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Categroy entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "categroy", catalog = "new_manage")
public class Categroy implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = -3283120192296322620L;
	private Integer id;
	private Categroy categroy;
	private String name;
	private Set<NewsInfo> newsInfos = new HashSet<NewsInfo>(0);
	private Set<Categroy> categroies = new HashSet<Categroy>(0);

	// Constructors

	/** default constructor */
	public Categroy() {
	}

	/** minimal constructor */
	public Categroy(String name) {
		this.name = name;
	}

	/** full constructor */
	public Categroy(Categroy categroy, String name, Set<NewsInfo> newsInfos,
			Set<Categroy> categroies) {
		this.categroy = categroy;
		this.name = name;
		this.newsInfos = newsInfos;
		this.categroies = categroies;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "parent_id")
	public Categroy getCategroy() {
		return this.categroy;
	}

	public void setCategroy(Categroy categroy) {
		this.categroy = categroy;
	}

	@Column(name = "name", nullable = false, length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(targetEntity = NewsInfo.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "categroy")
	public Set<NewsInfo> getNewsInfos() {
		return this.newsInfos;
	}

	public void setNewsInfos(Set<NewsInfo> newsInfos) {
		this.newsInfos = newsInfos;
	}

	@OneToMany(targetEntity = Categroy.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "categroy")
	public Set<Categroy> getCategroies() {
		return this.categroies;
	}

	public void setCategroies(Set<Categroy> categroies) {
		this.categroies = categroies;
	}

}